/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;
import model.Reports;
import model.Routes;

/**
 *
 * @author Adam
 */
@WebService(serviceName = "WSTest")
public class WSTest {

    @PersistenceUnit
    EntityManagerFactory emf;
    /**
     * This is a sample web service operation
     */
    @WebMethod
    public List<String> getReports() {
       List<Reports> rep= emf.createEntityManager().createNamedQuery("Reports.findAll").getResultList();
       List<String> report = new ArrayList<String>();
        for (Reports report_ : rep) {
            report.add("Mesto: "+report_.getCity()+"\nUlica: "+report_.getStreet()+"\nStat: "+report_.getState()+"\nPopis: "+report_.getDescription()+"\nVidena: "+report_.getSeen().toString()+"\nPocet palcov hore: "+report_.getNThumbUps()+"\nPocet palcov dole: "+report_.getNThumbDowns()+"\nPocet komentarov: " +report_.getNComments()+"\nLatitude: "+report_.getLatitude()+"\nLongitude: "+report_.getLongitude()+"\nTyp udalosti: "+report_.getTypeId().getTitle());
        }
        return report;
    }
    
    @WebMethod
    public List<String> getRoutes() {
       List<Routes> routes= emf.createEntityManager().createNamedQuery("Routes.findAll").getResultList();
       List<String> routes_ = new ArrayList<String>();
        for (Routes route : routes) {
            routes_.add("Mesto start: "+route.getSCity()+"\nUlica start: "+route.getSStreet()+"\nStat start: "+route.getSState()+"\nLatitude start: " +route.getSLatitude()+"\nLongitude start: "+route.getSLongitude()+"\nMesto koniec: "+route.getECity()+"\nUlica koniec: "+route.getEStreet()+"\nStat koniec: "+route.getEState()+"\nLatitude koniec: " +route.getELatitude()+"\nLongitude koniec: "+route.getELongitude()+"\nPocet hliadok: "+route.getNPatrol() +"\nPocet mobilnych radarov: "+route.getNMobileradar()+"\nPocet radarov: "+route.getNPolice() + "\nPocet nehod: "+route.getNAccident());
        }
        return routes_;
    }
}
